package com.bds.btcdc.web.service;

import com.bds.btcdc.web.model.StrategyOneArgs;
import org.apache.log4j.Logger;
import org.nutz.dao.Cnd;
import org.nutz.dao.impl.NutDao;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by DongChenchen on 2018/5/7 0007
 */
@Service
public class StrategyOneService {
    private Logger LOGGER = org.apache.log4j.Logger.getLogger(getClass());
    @Resource
    private NutDao dao;

    public List<StrategyOneArgs> getAll(){
        return dao.query(StrategyOneArgs.class, Cnd.where("1", "=", 1));
    }


    public StrategyOneArgs getOneByUserId(Long user_id){
        return dao.fetch(StrategyOneArgs.class, Cnd.where("user_id", "=", user_id));
    }
    public Boolean update(StrategyOneArgs ur){
        if(ur.getId()==null){
            return dao.insert(ur)==null?false:true;
        }else {
            return dao.update(ur) == 1 ? true : false;
        }
    }


    public void test(){
        dao.create(StrategyOneArgs.class,false);
    }

}
